package cn.com.w.secutity.Security.config;


import cn.com.w.secutity.Security.JwtTokenUtils;
import cn.com.w.secutity.Security.filter.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author w
 * @Description:
 * @DateTime: 2025 04 25 11:40
 **/
@Configuration
public class CommonSecurityConfig {

    // 注册白名单 Bean
    @Bean
    public IgnoreUrlsConfig ignoreUrlsConfig() {
        return new IgnoreUrlsConfig();
    }

    // 注册 JWT 工具类 Bean
    @Bean
    public JwtTokenUtils jwtTokenUtil() {
        return new JwtTokenUtils();
    }

    // 注册自定义认证失败逻辑 Bean
    @Bean
    public RestAuthenticationEntryPoint restAuthenticationEntryPoint() {
        return new RestAuthenticationEntryPoint();
    }

    // 注册自定义权限不足处理 Bean
    @Bean
    public RestfulAccessDeniedHandler restfulAccessDeniedHandler() {
        return new RestfulAccessDeniedHandler();
    }

    // 注册 JWT 登录授权过滤器 Bean
    @Bean
    public JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter() {
        return new JwtAuthenticationTokenFilter();
    }
}